import 'package:dmz/base/pageWidget/base_stateful_widget.dart';
import 'package:dmz/base/widget/defult_widget.dart';
import 'package:dmz/business/login/widgets/login_widgets.dart';
import 'package:dmz/business/mine/controller/seting_main_controller.dart';
import 'package:dmz/user/user_defurl.dart';
import 'package:dmz/utils/keyboard_util.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

class SetChangePasswordPage extends BaseStatefulWidget<SetingMainController> {
  const SetChangePasswordPage({super.key});

  @override
  String titleString() =>
      (EMIBUserManger().user?.password_set ?? true) ? '修改密码'.tr : '设置密码'.tr;

  @override
  get updateId => 'setPassword';

  @override
  bool delectControll() => false;

  @override
  Widget buildContent(BuildContext context) {
    return Container(
        color: Colors.transparent,
        child: Column(children: [
          if (!(EMIBUserManger().user?.password_set ?? true))
            Obx(() => LoginWidgets.setPassWordWidget(
                  controller.setPhoneNumCt,
                  controller.setPhoneCodeCt,
                  codeType: controller.snedCodeType.value,
                  countdownStr: '${controller.counter.value}s',
                  sendCode: controller.snedCode,
                )),
          if ((EMIBUserManger().user?.password_set ?? true))
            LoginWidgets.inputWidget(
                    hintText: '请输入原始密码'.tr,
                    controller: controller.setPassWordACt,
                    keyboardType: TextInputType.text)
                .marginOnly(bottom: 20.sp),
          LoginWidgets.inputWidget(
                  hintText: '请输入新密码'.tr,
                  controller: controller.setPassWordBCt,
                  keyboardType: TextInputType.text)
              .marginOnly(bottom: 20.sp),
          LoginWidgets.inputWidget(
                  hintText: '请再次输入新密码'.tr,
                  controller: controller.setPassWordCCt,
                  keyboardType: TextInputType.text)
              .marginOnly(bottom: 48.sp),
          DefaultBtn(click: () => controller.changePassWord(), title: '确认'.tr)
        ])).addGestureDetector(() => KeyboardUtils.hideKeyboardGex());
  }
}
